A full-system ISA emulator is a tool which supports running operating systems and applications of one ISA platform on another ISA platform, for example, running x86 Linux and corresponding applications on a PowerPC machine. It is an important method to extend the usage of an existing platform, to migrate servers between different ISA platforms, to develop and debug software of a pre-hardware system on an existing platform, etc.
Currently, full-system ISA emulators can be categorized into two classes: 1) interpretation-based ones, which sequentially interpret and emulate each instruction of a target ISA on a host platform, and; 2) binary-translation-based ones, which when encountering a section of non-translated target binary codes, translate them to host binary codes, then store the translated codes into the translation cache, and finally execute the translated codes directly. Usually the binary-translation-based emulators achieve higher performance than the interpretation-based ones, since they interpret and emulate many target instructions in a batch, instead of only one instruction each time.
Typically, binary-translation-based emulators check if a section of target binary codes has been translated in the following way: 1) calculating the starting physical address of the target binary codes, and; 2) searching the translation cache for the address. If found it means the code section has already been translated. Therefore, the translation results are indexed by the physical address of target binary codes. Since the physical address of binary codes may change after the program exists and re-executes, the translation results cannot be stored in permanent media, such as a hard-disk. So in the case of cache replacement, current binary-translation-based emulators have to discard some translated codes, and re-translate them when encountering them again. Another common way to improve the performance of an emulator is to dynamically optimize the translated codes based on, for example, profiling. The optimized codes cannot be saved in the permanent media due to the above-mentioned reason about index by physical address. Since both optimization and translation are time consuming, re-translating and re-optimizing the codes will degrade the overall performance of an emulator.
Consequently, there is a need for a new way to index the translation results and to store the translation results in the permanent media in this way. It is known that the code page of a program is the only part which needs to be translated and optimized. That is to say, the code page of a program is the unique feature thereof. If the content of the code page can be used, i.e., translation and optimization results can be indexed based on the content, then these translation results can be stored in the permanent media.
Although the translation results can be stored permanently using the aforesaid idea, since all applications in a full-system ISA emulator are run on an emulated OS (operating system) instead of the emulator directly, the full-system ISA emulator can only see the instruction flows, the machine states, and the memory mapping, but cannot differentiate different programs and recognize separate processes. Since the processes cannot be recognized separately by the full-system ISA emulator, even though the translation results indexed by content are stored permanently using the aforesaid idea, they can only be put into a huge translation repository instead of many application-dedicated process repositories. Obviously, since the process cannot be recognized, the full-system ISA emulator will look up the stored translation results in the huge translation repository, which is time-consuming. And maintenance of a huge translation repository results in much more overhead and cost than a small process repository.
Additionally, full-system ISA emulators are also often used to generate the profiling data for applications. However, full-system ISA emulators can hardly generate the profiling data dedicated for target applications without interleaving of other concurrent applications, since they cannot recognize the processes separately.
Therefore, there is a need for a method of recognizing a process in a full-system ISA emulator and saving the content-based dynamic binary translation in the full-system ISA emulator by the recognized process.